﻿#pragma once

#include "../../MirControls/MirImageControl.h"
#include "../../MirControls/MirLabel.h"
#include "../../MirControls/MirButton.h"
#include "../../MirControls/MirControl.h"
#include "../../KeyBindSettings.h"
#include <string>
#include <vector>
#include <cmath>
#include <any>
#include "../../../stringhelper.h"

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirSounds;

namespace Client::MirScenes::Dialogs
{
    class KeyboardLayoutDialog final : public MirImageControl
    {
    public:
        MirImageControl *TitleLabel, *EnforceButtonChecked;
        MirLabel *PageLabel, *EnforceButtonLabel;
        MirButton *CloseButton;

        MirButton *ScrollUpButton, *ScrollDownButton, *PositionBar;
        MirButton *ResetButton, *EnforceButton;

        std::vector<MirControl*> Rows = std::vector<MirControl*>();

        bool Enforce = true;

        int TopLine = 0;
        int LineCount = 16;

        int PosX = 491, PosMinY = 101, PosMaxY = 344;

        KeyBind *WaitingForBind = nullptr;

        virtual ~KeyboardLayoutDialog()
        {
            delete TitleLabel;
            delete EnforceButtonChecked;
            delete PageLabel;
            delete EnforceButtonLabel;
            delete CloseButton;
            delete ScrollUpButton;
            delete ScrollDownButton;
            delete PositionBar;
            delete ResetButton;
            delete EnforceButton;
            delete WaitingForBind;
        }

        KeyboardLayoutDialog();

    private:
        void EnforceButton_Click(std::any sender, EventArgs *e);

    public:
        void UpdateText();

    private:
        void UpdatePositionBar();

        void PositionBar_OnMoving(std::any sender, MouseEventArgs *e);

    public:
        void CheckNewInput(KeyEventArgs *e);
    };

    class KeybindRow final : public MirControl
    {
    public:
        MirLabel *BindName, *DefaultBind;
        MirButton *CurrentBindButton;

        KeyBind *KeyBind;

        virtual ~KeybindRow()
        {
            delete BindName;
            delete DefaultBind;
            delete CurrentBindButton;
            delete KeyBind;
        }

        KeybindRow(KeybindOptions option);
    };

    class KeybindHeadingRow final : public MirControl
    {
    public:
        MirImageControl *BulletImage, *SpacerImage;
        MirLabel *BulletLabel;

        virtual ~KeybindHeadingRow()
        {
            delete BulletImage;
            delete SpacerImage;
            delete BulletLabel;
        }

        KeybindHeadingRow(const std::string &groupName);
    };

}
